
import java.io.*;
import java.net.*;


public class TCPClientPersoana extends Thread {

    private String serverIP;
    private int serverPort;
  

    public TCPClientPersoana(String serverIP, int serverPort) {
        this.serverIP = serverIP;
        this.serverPort = serverPort;
       
    }

    public void run() {
        try {
            Socket clientSocket = new Socket(this.serverIP, this.serverPort);
            System.out.println("Conectare reusita la " + this.serverIP);
            ObjectInputStream in = new ObjectInputStream(clientSocket.getInputStream());

            //receive obiect de tip Persoana
            Persoana auxPersoana = (Persoana) in.readObject();
            System.out.println(auxPersoana);
        } catch (Exception e) {
            System.err.println("TCPClient-" + this.hashCode() + " exception: " + e);
            e.printStackTrace();
        }

    }
    public static void main (String ... arg){

        TCPClientPersoana client=new TCPClientPersoana("localhost", 20001);
        client.start();
        
    }
}
